//
//  BizAlertView.m
//  ent
//
//  Created by shirokuma on 15/5/18.
//  Copyright (c) 2015年 ND. All rights reserved.
//

#import "BizAlertView.h"
#import <SmartCan/NSError+SMCHelper.h>
@interface BizAlertView()
@property (nonatomic,strong) NSDictionary * errDict;
@end
@implementation BizAlertView


/**
* 自定义信息成功提示框
*/
-(instancetype)initSuccessAlertWithMessage:(NSString *)message {
    
    self = [super init];
    if(self){
        self = [self initWithTitle:@"成功" message:message delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
    }
    return self;
}

/**
* 提供针对业务错误码的提示框
*/
-(instancetype)initErrorAlertWithError:(NSError *)error {
    
    self = [super init];
    if(self){
        
        _errDict = @{
                     @"-1009":@"网络断掉啦",
                     @"UC/PHONE_HAS_REGISTER":@"您已经注册过咯，快去登录吧",
                     @"UC/USER_NOT_EXIST":@"该手机号尚未注册"
                     };
        
        NSString *msg = [self.errDict valueForKey:[NSString stringWithFormat:@"%@",error.smc_errorCode]];
        if(nil == msg && msg.length == 0){
            msg = error.smc_localizedDescription;
        }
        self = [self initWithTitle:@"错误" message:msg delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
    }
    return self;

}

/**
 * 自定义信息错误提示框
 */
-(instancetype)initErrorAlertWithMessage:(NSString *)message {
    
    self = [super init];
    if(self){
        self = [self initWithTitle:@"错误" message:message delegate:self cancelButtonTitle:@"确认" otherButtonTitles:nil, nil];
    }
    return self;
    
}
@end

